<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>slot插槽</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <style>
        *{
            margin: 0 ;
            padding: 0;
        }
        .header{
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin: 0 auto;
            box-shadow: 0 0 10px #bfbfbf;
            padding: 15px;
        }
        .header > div{
            text-align: center;
        }
        .header > div:nth-child(1){
            width: 30%;
        }
        .left-div:hover{
            color:#fff;
            background: cornflowerblue;
        }
        .header > div:nth-child(2){
            width: 40%;
        }
        .header > div:nth-child(3){
            width: 30%;
        }
        .left-div{
            width: 100px;
            text-align: center;
            border-radius: 20px;
            border: solid 1px red;
            display: flex;
            flex-direction: row;
            align-items: center;
        }
        .leftDiv{
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: chocolate;
            margin-left: 16px;
            border: solid 5px rgb(194, 185, 248);
        }
        .left-div h2{
            font-size: 14px;
            color: #333;
            margin-left: 10px;
        }
        .right-div{
            display: flex;
            flex-direction: row;
            text-align: center;
        }
        .right-div > span{
            width: 20px;
            height: 20px;
            border: solid 1px #ddd;
            border-radius: 50%;
            position: relative;
            display: block;
        }
        .right-div > span::after{
            content: '';
            display: block;
            width: 2px;
            height: 10px;
            transform: rotate(125deg);
            position: absolute;
            background: #aaa;
            top: 14px;
            left: 22px;
                }
        .right-div > p{
            width: 100px;
            border: solid 1px #252525;
            border-radius: 20px;
            font-size: 14px;
            margin-left: 10px;
        }
    </style>
</head>
<body>
    <div id="app"></div>
    <script>
        let header = {
            template:`
            <div class="header">
                <div class="one" @click="fun">
                    <slot name="left"></slot>    
                </div>
                <div class="two">
                    <slot name="center"></slot>    
                </div>
                <div class="three">
                    <slot name="right"></slot>    
                </div>
            </div>
            `,
            methods:{
                fun(){
                    console.log(111)
                }
            }
        }
        let app = {
            template:`
            <div>
                <Header>
                    <div class="left-div" slot="left">
                        <div class="leftDiv"></div>
                        <h2>圈子</h2>
                    </div>
                    <p slot="center">会玩</p>
                    <div class="right-div" slot="right">
                        <span></span>
                        <p>发帖子</p>
                    </div>
                </Header>
                <br>
                <hr>
                <br><br>
                <Header>
                    <p slot="center">消息</p>
                    <div class="right-div" slot="right">
                        <span></span>
                    </div>
                </Header>
            </div>
            `,
            components:{ 'Header':header },
            data(){
                return{}
            }
        }
        new Vue({
            render:function(a){
                return a(app)
            }
        }).$mount('#app')
    </script>
</body>
</html>